<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>main</title>
<jsp:include page="../head.jsp" />
<script type="text/javascript">

	function save(){
		if(trim($("#departmentName").val())==""){
			addError("departmentName","部门名称不能为空.");
			return;
		}else if(trim($("#departmentNo").val())==""){
			addError("departmentNo","部门编号不能为空.");
			return;
		}
		if (!checkForm(document.getElementById("saveForm"))) {
			return;
		}
		xbox.load("loading");	
		$("#saveForm").ajaxSubmit(function(){
			  $("#refreshForm").submit();
	    });
	}
	function turnBack(){
		$("#refreshForm").submit();
	}

</script>

</head>
<body>
<form action="<%=path%>/department/department_modify_listAction.action" method="post" id="saveForm">
<table width="98%" align="center" border="0" cellpadding="4" cellspacing="1" bgcolor="#F1F1F1" style="margin-bottom:8px">
  <tr bgcolor="#FFFFFF">
    <td colspan="4" height="16"><span></span></td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="10%" align="right" bgcolor="#FFFFFF"><span style="color:red;">*</span>部门名称：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
              <input maxlength="25" type="text" name="department.departmentName" id="departmentName" value="${department.departmentName}" />
    </td>
    <td width="10%" align="right" bgcolor="#FFFFFF"><span style="color:red;">*</span>部门编号：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
              <input maxlength="25" type="text" name="department.departmentNo" id="departmentNo" value="${department.departmentNo}" />
    </td>
  </tr>
   <tr bgcolor="#FFFFFF">
    <td width="10%" align="right" bgcolor="#FFFFFF">所属公司：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
    	<c:choose>
	    	<c:when test='${fn:contains(sessionScope.sessionRoleIds,",1,")}'>
	    		<select id="companyId" name="companyId">
		    	<option value="0">&nbsp;&nbsp;&nbsp;&nbsp;</option>
		    	<c:forEach items="${companyList}" var="comp">
		    		<option value="${comp.companyId}" <c:if test="${department.company.companyId eq comp.companyId}">selected="selected"</c:if>><c:out value="${comp.companyName}" /></option>
		    	</c:forEach>
	    	</select>
	    	</c:when>
	    	<c:otherwise>
	    		${sessionScope.sessionUser.company.companyName}<input type="hidden" name="companyId" value="${sessionScope.sessionUser.company.companyId}"/>
	    	</c:otherwise>
	    </c:choose>
    </td>
    <td width="10%" align="right" bgcolor="#FFFFFF">上级部门：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
    <select id="parentDepartmentId" name="department.parentDepartmentId">
    	<option value="0">无上级部门</option>
    	<c:forEach items="${departmentList}" var="dep">
    	<option value="${dep.departmentId}" <c:if test="${dep.departmentId eq department.parentDepartmentId}">selected="selected"</c:if>><c:out value="${dep.departmentName}" /></option>
    	</c:forEach>
    </select>
    </td>
   </tr>
   <tr bgcolor="#FFFFFF">
    <td width="10%" align="right" bgcolor="#FFFFFF">电话：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
              <input type="text" name="department.departmentPhone" id="departmentPhone" value="${department.departmentPhone}" />
    </td>
    <td width="10%" align="right" bgcolor="#FFFFFF">Email：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
              <input type="text" name="department.departmentEmail" id="departmentEmail" value="${department.departmentEmail}" />
    </td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="10%" align="right" bgcolor="#FFFFFF">传真：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
              <input type="text" name="department.departmentFax" id="departmentFax" value="${department.departmentFax}" />
    </td>
    <td width="10%" align="right" bgcolor="#FFFFFF">地址：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
              <input type="text" name="department.departmentAddress" id="departmentAddress" value="${department.departmentAddress}" />
    </td>
  </tr>
  <tr bgcolor="#FFFFFF">
  	<td width="10%" align="right" bgcolor="#FFFFFF">部门经理：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
              <input type="text" name="department.departmentManager" id="departmentManager" value="${department.departmentManager}" />
    </td>
    <td width="10%" align="right" bgcolor="#FFFFFF">部门职责：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
              <input type="text" name="department.departmentDuty" id="departmentDuty" value="${department.departmentDuty}" />
    </td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="10%" align="right" bgcolor="#FFFFFF">备注：</td>
    <td width="90%" colspan="3" align="left" bgcolor="#FFFFFF">
              <textarea rows="3"  name="department.remark" id="remark">${department.remark}</textarea>
    </td>
  </tr>
  <tr align="right" bgcolor="#F1F1F1">
	<td height="36" colspan="4" align="center">
		<input type='button' class="btn btn-primary" id="btnSave" onclick="save();" value='保存' />
	    &nbsp;<input type='button' class="btn" onclick="turnBack();" value='返回' />
</td>
</tr>
</table>

<input type="hidden" name="department.departmentId" value="${department.departmentId}"/>
<input type="hidden" name="department.createTime" value="${department.createTime}"/>
<input type="hidden" name="department.deleteFlag" value="${department.deleteFlag}"/>
</form>

<form action="${listUrl}" method="post" style="display: none;" id="refreshForm" name="refreshForm"/>
	

</body>
</html>
